<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:p="http://primefaces.org/ui"
	template="/templates/template.xhtml" xmlns:eq="http://www.equus.com.br/facelets/">

	<f:metadata>
		<f:event type="preRenderView" listener="#{controleReproducaoMBean.verificarAcesso}" />
	</f:metadata>

	<ui:define name="body">
		<h:form id="form" prependId="false">
			<h:panelGrid id="tagOs" width="100%">
				<eq:animal animal="#{controleReproducaoMBean.animal}" />
			</h:panelGrid>
			<p:fieldset legend="#{controleReproducaoMBean.qualifiedName}" id="fieldPrincipal">
				<h:panelGrid columns="4" id="panelCadastro" columnClasses="coluna20,coluna30,coluna20,coluna40" width="100%">

					<h:outputText value="Data Coleta:" styleClass="icoObrigatorio" />
					<h:panelGrid columns="2" cellpadding="0" cellspacing="0">
						<p:calendar locale="pt" pattern="dd/MM/yyyy" id="dtColeta" navigator="true" maxlength="10" size="20"
							readOnlyInputText="true" value="#{controleReproducaoMBean.model.dtColeta}" mode="popup" showOn="button"
							requiredMessage="#{controleReproducaoMBean.requiredMessage}" required="true" />
						<p:commandLink process="@this" title="Limpar" update="dtColeta">
							<h:graphicImage name="icone-limpar.png" library="design/imagem" />
							<f:setPropertyActionListener target="#{controleReproducaoMBean.model.dtColeta}" value="" />
						</p:commandLink>
					</h:panelGrid>
					<p:message for="dtColeta" />
					<h:outputText value=" " />


					<h:outputText value="Código Palheta:" styleClass="icoObrigatorio" />
					<p:inputText value="#{controleReproducaoMBean.model.codigoPalheta}"
						requiredMessage="#{controleReproducaoMBean.requiredMessage}" required="true" id="codPalheta" size="20"
						maxlength="10" />
					<p:message for="codPalheta" />
					<h:outputText value=" " />


					<h:outputText value="Dose de Ejaculado:" styleClass="icoObrigatorio" />
					<p:inputText value="#{controleReproducaoMBean.model.dosePalhetaToString}"
						requiredMessage="#{controleReproducaoMBean.requiredMessage}" required="true" id="dosePalheta" size="20"
						maxlength="10" />
					<p:message for="dosePalheta" />
					<h:outputText value=" " />


					<h:outputText value="Quantidade Palheta:" styleClass="icoObrigatorio" />
					<p:inputMask mask="9?999" value="#{controleReproducaoMBean.model.qtdPalheta}"
						requiredMessage="#{controleReproducaoMBean.requiredMessage}" required="true" id="qtdPalheta" size="10"
						maxlength="4" />
					<p:message for="qtdPalheta" />
					<h:outputText value=" " />

					<h:outputText value="Motilidade %:" styleClass="icoObrigatorio" />
					<p:inputText value="#{controleReproducaoMBean.model.motilidaProToString}"
						requiredMessage="#{controleReproducaoMBean.requiredMessage}" required="true" id="motiPro" size="10" maxlength="10" />
					<p:message for="motiPro" />
					<h:outputText value=" " />

					<h:outputText value="Motilidade Pós Desconge.:" styleClass="icoObrigatorio" />
					<p:inputText value="#{controleReproducaoMBean.model.motilidaProCongeladaToString}"
						requiredMessage="#{controleReproducaoMBean.requiredMessage}" required="true" id="motConge" size="10"
						maxlength="10" />
					<p:message for="motConge" />
					<h:outputText value=" " />

					<h:outputText value="Concentração espermática:" />
					<p:inputText value="#{controleReproducaoMBean.model.concentracaoEspermaToString}" id="conEspe" size="20"
						maxlength="10" />
					<p:message for="conEspe" />
					<h:outputText value=" " />

					<h:outputLabel value="Observação:" />
					<p:inputTextarea value="#{controleReproducaoMBean.model.observacao}" id="obs" cols="60" rows="6" autoResize="false" />
					<h:outputText value=" " />
					<h:outputText value=" " />
				</h:panelGrid>
				<br />
			</p:fieldset>

			<p:toolbar>
				<p:toolbarGroup align="left">
					<p:commandButton value="Voltar" immediate="true" ajax="false" action="pesquisarAnimal.jsf" />
					<p:commandButton value="Limpar" immediate="true" ajax="false" action="#{controleReproducaoMBean.limparTela}" />
					<p:commandButton rendered="#{p:ifGranted('ROLE_REPRO_M_SALVAR')}" value="Salvar" ajax="true" process="@form"
						update="@form" action="#{controleReproducaoMBean.save}" />
				</p:toolbarGroup>
			</p:toolbar>
			<br />
			<p:dataTable var="lista" id="lista" emptyMessage="#{controleReproducaoMBean.emptyMessage}" update="lista"
				rowsPerPageTemplate="#{controleReproducaoMBean.paginacao}" styleClass="coluna100"
				value="#{controleReproducaoMBean.lazyDataModel}" paginator="true" rows="5"
				rowStyleClass="#{empty rowIx or rowIx mod 2 ne 0 ? 'linhaImpar' : 'linhaPar'}" rowIndexVar="rowIx">

				<p:column headerText="Data Coleta" sortBy="#{lista.dtColeta}" style="width:10%">
					<h:outputLabel value="#{lista.dtColeta}">
						<f:convertDateTime pattern="dd/MM/yyyy" />
					</h:outputLabel>
				</p:column>
				<p:column headerText="Código Palheta" sortBy="#{lista.codigoPalheta}" filterBy="#{lista.codigoPalheta}"
					style="width:20%">
					<h:outputLabel value="#{lista.codigoPalheta}" />
				</p:column>
				<p:column headerText="Dose de Ejaculado" sortBy="#{lista.dosePalheta}" style="width:20%">
					<h:outputLabel value="#{lista.dosePalheta}" />
				</p:column>
				<p:column headerText="Quantidade Palheta" sortBy="#{lista.qtdPalheta}" filterBy="#{lista.qtdPalheta}"
					style="width:20%">
					<h:outputLabel value="#{lista.qtdPalheta}" />
				</p:column>
				<p:column headerText="Motilidade %" sortBy="#{lista.motilidaPro}" style="width:20%">
					<h:outputLabel value="#{lista.motilidaPro}" />
				</p:column>

				<p:column headerText="Ações" style="width:20%;text-align:center;">
					<p:commandLink rendered="#{p:ifGranted('ROLE_REPRO_M_EDITAR')}" title="Editar" style="padding:5px !important;"
						update=":form:panelCadastro" process="@this" action="#{controleReproducaoMBean.load}">
						<h:graphicImage library="design/imagem" name="icone-editar.png" />
						<f:setPropertyActionListener target="#{controleReproducaoMBean.model}" value="#{lista}" />
					</p:commandLink>
					<p:commandLink rendered="#{p:ifGranted('ROLE_REPRO_M_EXCLUIR')}" title="Excluir" process="@this"
						oncomplete="confirmation.show()">
						<h:graphicImage library="design/imagem" name="icone-excluir.png" />
						<f:setPropertyActionListener target="#{controleReproducaoMBean.model}" value="#{lista}" />
					</p:commandLink>
				</p:column>
			</p:dataTable>

			<p:dialog appendToBody="true" header="Calculadora Espermática" height="400" width="500" widgetVar="calc">
				<h:outputText value="text" />
			</p:dialog>
			<p:confirmDialog appendToBody="true" message="Confirma a Exclusão" header="Exclusão" severity="alert"
				widgetVar="confirmation">
				<h:panelGrid columns="2">
					<p:commandButton value="Sim" update="lista" oncomplete="confirmation.hide()"
						actionListener="#{controleReproducaoMBean.delete}" immediate="true" />
					<p:commandButton value="Não" onclick="confirmation.hide()" />
				</h:panelGrid>
			</p:confirmDialog>
		</h:form>
	</ui:define>
</ui:composition>